package kuba.bean;


import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotBlank;


public class CD {
    @NotBlank
    @Size(min=5,max=30)
    private String title;
    
    @NotNull
    @Min(0)
    private int id;
    
    @NotBlank
    @Size(min=3,max=15)
    private String genere;
    
    @NotNull
    @Min(0)
    private int  authorId;
    

    
    public CD () {

    }
    

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getGenere() {
        return genere;
    }

    public void setGenere(String genere) {
        this.genere = genere;
    }

    public int getAuthorId() {
        return authorId;
    }

    public void setAuthorId(int authorId) {
        this.authorId = authorId;
    }

    
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        
        builder.append(id).append(" ").append(title).append(" ").append(genere);
        return builder.toString();
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + authorId;
        result = prime * result + ((genere == null) ? 0 : genere.hashCode());
        result = prime * result + id;
        result = prime * result + ((title == null) ? 0 : title.hashCode());
        return result;
    }


    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        CD other = (CD) obj;
        if (authorId != other.authorId) {
            return false;
        }
        if (genere == null) {
            if (other.genere != null) {
                return false;
            }
        } else if (!genere.equals(other.genere)) {
            return false;
        }
        if (id != other.id) {
            return false;
        }
        if (title == null) {
            if (other.title != null) {
                return false;
            }
        } else if (!title.equals(other.title)) {
            return false;
        }
        return true;
    }





}
